package ua.kharkov.khpi.tarasenko.bach.core.logging;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class CustomerSession {

	private Date sessionStartDate;
	private int sessionId;
	private int userId;
	private List<TransTypePair> transactions = new ArrayList<TransTypePair>();

	public int getSessionId() {
		return sessionId;
	}

	public void setSessionId(int sessionId) {
		this.sessionId = sessionId;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public void addTransaction(TransTypePair trans) {
		getTransactions().add(trans);
	}

	public List<TransTypePair> getTransactions() {
		return transactions;
	}

	public void setTransactions(
			List<TransTypePair> transactions) {
		this.transactions = transactions;
	}
	
	public Date getSessionStartDate() {
		return sessionStartDate;
	}
	
	public void setSessionStartDate(Date sessionStartDate) {
		this.sessionStartDate = sessionStartDate;
	}

	@Override
	public String toString() {
		String result = "";
		result = result + "uid:" + userId;
		result = result + "\n";
		result = result + "sessionId:" + sessionId;
		result = result + "\n";
		for (TransTypePair transaction : transactions) {
			result = result + "\t";
			switch (transaction.getTransactionType()) {
			case VIEW:
			case CART:
				result = result + "iid:";
				break;
			case BUY:
				result = result + "oid:";
				break;
			default:
				result = result + "lol?";
				break;
			}
			result = result + transaction.getItemId() + "-"
					+ transaction.getTransactionType();
			result = result + "\n";
		}
		result = result + "start time:" + sessionStartDate;
		result = result + "\n";
		return result;
	}
}
